# day9数据合并与统计 
import pandas as pd

def concat_and_mean():
    # 创建两个DataFrame
    data1 = pd.DataFrame({'A': [1, 2, 3], 'B': [4, 5, 6]})
    data2 = pd.DataFrame({'A': [4, 5, 6], 'B': [7, 8, 9]})
    
    print("data1:\n", data1)
    print("data2:\n", data2)
    
    # 合并两个DataFrame，纵向拼接，重置索引
    merged_data = pd.concat([data1, data2], ignore_index=True)
    print("\n合并后的数据：\n", merged_data)
    
    # 计算每一列的均值
    col_mean = merged_data.mean(numeric_only=True)
    print("\n每一列的均值：\n", col_mean)

if __name__ == "__main__":
    concat_and_mean() 

    

